package com.zfl.thread.day04;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CompletableFutureDemo07 {
    private static int sum;
    public static void main(String[] args) {

        ExecutorService pool = Executors.newFixedThreadPool(2);
        CompletableFuture completableFuture = CompletableFuture.runAsync(()->{
            for (int i = 0; i < 100; i++) {
                sum+=i;
            }
            System.out.println("sum:"+sum);
        },pool);
        System.out.println(Thread.currentThread().getName()+"正在运行");
        pool.shutdown();

    }
}
